Segment Maps
malloy can create segment maps. By currently it uses US maps and state names.
Segement maps take as input a series take a table with 4 columns, lat, long, lat, long of the segment.
The model and data styles for the subsequent examples is:
define airports is (explore 'malloy-data.faa.airports' primary key code airport_count is count(*) ); define flights is (explore 'malloy-data.faa.flights' primary key id2 origin_code renames origin destination_code renames destination flight_count is count(*) routes_map is (reduce origin.latitude origin.longitude latitude2 is destination.latitude longitude2 is destination.longitude flight_count ) joins origin is airports on origin_code, destination is airports on destination_code );
and data styles are
{ "routes_map": { "renderer": "segment_map" } }
Run as a simple query.
Depararting from Chicago
explore flights : [dep_time : @2003-02, origin.code : 'ORD'] | routes_map
Run as a turtle.
explore flights : [dep_time : @2003-02, origin.code : 'ORD'] | reduce routes_map
| routes_map |
|---|
Run as a trellis.
explore flights : [dep_time : @2003-02, origin.code : 'ORD'] | reduce carrier flight_count routes_map
| carrier | flight_count | routes_map |
|---|---|---|
| UA | 9,443 | |
| AA | 7,255 | |
| MQ | 4,975 | |
| DH | 3,906 | |
| NW | 702 |
Run as a trellis repeated filtered
explore flights : [dep_time : @2003-02] | reduce : [origin.code : 'ORD'|'SFO'|'JFK'] carrier flight_count ord is routes_map : [ origin.code: 'ORD'] sfo is routes_map : [ origin.code: 'SFO'] jfk is routes_map : [ origin.code: 'JFK']
| carrier | flight_count | ord | sfo | jfk |
|---|---|---|---|---|
| UA | 13,584 | |||
| AA | 9,271 | |||
| MQ | 5,885 | |||
| DH | 4,332 | |||
| OO | 2,338 |
Malloy